package com.digitalchina.lxnsy.activity.old;

import android.app.Dialog;
import android.graphics.Paint;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.ScrollView;
import android.widget.TextView;

import com.digitalchina.lxnsy.R;
import com.digitalchina.lxnsy.api.BusinessFarmSystem;
import com.digitalchina.lxnsy.base.BaseActivity;
import com.digitalchina.lxnsy.constant.Constant;
import com.digitalchina.lxnsy.constant.MSG;
import com.digitalchina.lxnsy.constant.URL;
import com.digitalchina.lxnsy.entity.EvaluationVO;
import com.digitalchina.lxnsy.entity.ProductInfoVO;
import com.digitalchina.lxnsy.toolkit.FastJsonUtil;
import com.digitalchina.lxnsy.toolkit.FrescoUtil;
import com.digitalchina.lxnsy.toolkit.GlideImageLoader;
import com.digitalchina.lxnsy.toolkit.GotoUtil;
import com.digitalchina.lxnsy.toolkit.Utils;
import com.digitalchina.lxnsy.widget.SlideDetailsLayout;
import com.facebook.drawee.view.SimpleDraweeView;
import com.youth.banner.Banner;
import com.youth.banner.BannerConfig;
import com.zhy.view.flowlayout.FlowLayout;
import com.zhy.view.flowlayout.TagAdapter;
import com.zhy.view.flowlayout.TagFlowLayout;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;

import static com.digitalchina.lxnsy.constant.URL.URL_HTML_PRODUCT_CONTENT;
import static com.digitalchina.lxnsy.toolkit.Utils.formatPrice;


/**
 * ================================================
 * 项目名称：YLCloud
 * 类描述：
 * 包名：com.digitalchina.ylcloud.activity
 * 创建人：郑皓
 * 创建时间：2016/5/24 17:02
 * 修改备注：
 * ================================================
 */
public class ProductDetailActivity extends BaseActivity {


    @Bind(R.id.headview_home_page_banner)
    Banner banner; // 顶部轮播图
    @Bind(R.id.product_detail_iv_presell)
    ImageView productDetailIvPresell; // 预售图标
    @Bind(R.id.product_detail_ll_top_dots)
    LinearLayout productDetailLlTopDots; // 小红点layout
    @Bind(R.id.product_detail_tv_title)
    TextView productDetailTvTitle;  // 标题
    @Bind(R.id.product_detail_tv_price)
    TextView productDetailTvPrice; // 价格
    @Bind(R.id.product_detail_tv_express)
    TextView productDetailTvExpress; // 邮费
    @Bind(R.id.product_detail_tv_sold_num)
    TextView productDetailTvSoldNum; // 已售数量
    @Bind(R.id.product_detail_tv_type)
    TextView productDetailTvType; // 类型
    @Bind(R.id.product_detail_iv_minus)
    ImageView productDetailIvMinus;  // 减数量
    @Bind(R.id.product_detail_tv_number)
    TextView productDetailTvNumber;  // 购买数量
    @Bind(R.id.product_detail_iv_plus)
    ImageView productDetailIvPlus; // 加数量
    @Bind(R.id.product_detail_tv_evaluate_num)
    TextView productDetailTvEvaluateNum; // 评价数量
    @Bind(R.id.product_detail_rl_evaluate)
    RelativeLayout productDetailRlEvaluate; // 评价layout 有点击事件
    @Bind(R.id.product_detail_iv_appraiser_icon)
    SimpleDraweeView productDetailIvAppraiserIcon; // 评价人头像
    @Bind(R.id.product_detail_tv_appraiser_name)
    TextView productDetailTvAppraiserName; // 评价人姓名
    @Bind(R.id.product_detail_tv_appraiser_content)
    TextView productDetailTvAppraiserContent; // 评价内容 //TODO 暂时修改为简要描述
    @Bind(R.id.product_detail_iv_farm_logo)
    SimpleDraweeView productDetailIvFarmLogo; // 农庄logo
    @Bind(R.id.product_detail_tv_farm_name)
    TextView productDetailTvFarmName; // 农庄名称
    @Bind(R.id.product_detail_tv_message)
    TextView productDetailTvMessage; // 分割线提示信息
    @Bind(R.id.product_detail_scrollview)
    ScrollView productDetailScrollview;
    @Bind(R.id.product_detail_webview)
    WebView productDetailWebview;
    @Bind(R.id.product_detail_slidedetails)
    SlideDetailsLayout productDetailSlidedetails;
    @Bind(R.id.product_detail_bt_reserve)
    Button productDetailBtReserve;
    @Bind(R.id.product_detail_ll_bottom)
    LinearLayout productDetailLlBottom;
    @Bind(R.id.product_detail_bt_add_cart)
    Button productDetailBtAddCart;//加入购物车
    @Bind(R.id.product_detail_ll_buyNum)
    LinearLayout productDetailLLBuyNumLayout;// 数量加减操作
    @Bind(R.id.product_detail_ll_evaluation)
    LinearLayout productDetailLLEvaluation;// 评价列表
    @Bind(R.id.product_detail_rl_choose_goods_property)
    RelativeLayout productDetailChooseGoodsProperty;// 选择商品属性
    @Bind(R.id.product_detail_tv_preferentialPrice)
    TextView productDetailPreferentialPrice;//  促销价格
    @Bind(R.id.relativeLayout_parent)
    RelativeLayout relativeLayoutParent;
    @Bind(R.id.product_detail_tv_loading)
    TextView productDetailTvLoading;
    // ================================================
    private ProductInfoVO productVO;
    private int buyNumber = 1;

    // ================================================
//    private ShareVO mShareVO;//分享VO
    private int msgWhat;//返回标识
    private boolean isCollected = false;//默认没有收藏

    //=================================================//产品属性相关
    private List<ProductInfoVO.AgricultureProductPriceListBean> agricultureList;//产品属性
    private String lowPrice, highPrice;// 原价价格(最低and最高)
    private String lowPreferPrice, highPreferPrice;// 促销价格(最低and最高)
    private String hasPreferentialPrice;// 是否有促销价
    private String hasProperty;// 有无产品属性 0--无 1--有

    private String evaluateInfo; // 评价统计
    private List<EvaluationVO> evaluationVOList = new ArrayList<>(); // 统计列表

    private String productId = "";

    @Override
    public void setLayout() {
        setContentLayout(R.layout.activity_product_detail);
        setTitle("商品详情");
    }

    @Override
    public void initMember() {

//        productVO = (ProductInfoVO) getIntent().getSerializableExtra("productInfoVO");

        productId = (String) getIntent().getSerializableExtra("productId");

        // 调用农产品详情接口
        BusinessFarmSystem.getProductInfo(this, productId, mHandler);
    }

    private void setContent() {


        // 标题
        productDetailTvTitle.setText(productVO.getName());

        // 价格
        if ("1".equals(hasPreferentialPrice)) {// 有促销价格
            if ("1".equals(hasProperty)) {// 有产品属性
                productDetailTvPrice.setText(String.format("价格:%s - %s元/%s", formatPrice(lowPrice), formatPrice(highPrice), productVO.getUnit().getName()));
                productDetailTvPrice.getPaint().setFlags(Paint.STRIKE_THRU_TEXT_FLAG);// 添加删除线
                productDetailPreferentialPrice.setText(String.format("￥ %s - %s元/%s", formatPrice(lowPreferPrice), formatPrice(highPreferPrice), productVO.getUnit().getName()));
            } else {
                productDetailTvPrice.setText(String.format("价格:%s元/%s", formatPrice(highPrice), productVO.getUnit().getName()));
                productDetailTvPrice.getPaint().setFlags(Paint.STRIKE_THRU_TEXT_FLAG);// 添加删除线
                productDetailPreferentialPrice.setText(String.format("￥ %s元/%s", formatPrice(highPreferPrice), productVO.getUnit().getName()));
            }
        } else {
            productDetailTvPrice.setVisibility(View.GONE);
            if ("1".equals(hasProperty)) {// 有产品属性
                productDetailPreferentialPrice.setText(String.format("￥ %s - %s元/%s", formatPrice(lowPrice), formatPrice(highPrice), productVO.getUnit().getName()));
            } else {
                productDetailPreferentialPrice.setText(String.format("￥ %s元/%s", formatPrice(lowPrice), productVO.getUnit().getName()));
            }
        }

        // 是否有产品属性
        if ("1".equals(hasProperty)) {// 有产品属性
            productDetailChooseGoodsProperty.setVisibility(View.VISIBLE);
            productDetailLLBuyNumLayout.setVisibility(View.GONE);
        } else {
            productDetailChooseGoodsProperty.setVisibility(View.GONE);
            productDetailLLBuyNumLayout.setVisibility(View.VISIBLE);
        }

        // 邮费 isFreePostage = 1 为包邮
        if (productVO.getIsFreePostage().equals("1"))
            productDetailTvExpress.setText("快递：包邮");
        else
            productDetailTvExpress.setText(String.format("快递：%s/元", formatPrice(productVO.getPostage() + "")));


        // 已售数量
        productDetailTvSoldNum.setText("已售：" + productVO.getSaleNum() + "件");

        // 类型
        productDetailTvType.setText(productVO.getType().getName());

        // TODO 评价数量
        productDetailTvEvaluateNum.setVisibility(View.VISIBLE);

        // 简要描述
        productDetailTvAppraiserContent.setText(productVO.getSummary());

        // 农庄logo
        FrescoUtil.showImageSmall(productVO.getFarmInfo().getLogo(), productDetailIvFarmLogo);

        // 农庄名称
        productDetailTvFarmName.setText(productVO.getFarmInfo().getName());

        // TODO 图文详情
        setWebView(URL_HTML_PRODUCT_CONTENT + productVO.getId());


        List<String> imagesList = new ArrayList<>();
        for (int i = 0; i < productVO.getProductImageList().size(); i++) {
            imagesList.add(URL.URL_SHOW_IMAGE + productVO.getProductImageList().get(i).getImage() + Constant.SHOW_IMAGE_TYPE_BIG);
        }
        //设置图片加载器
        banner.setImageLoader(new GlideImageLoader(0));
        //设置图片集合
        banner.setImages(imagesList);
        //设置标题
//        banner.setBannerTitles(titles);
        //设置自动轮播，默认为true
//        banner.isAutoPlay(true);
        //设置轮播时间
        banner.setDelayTime(3000);
        //设置风格
        banner.setBannerStyle(BannerConfig.NUM_INDICATOR);
        //banner设置方法全部调用完毕时最后调用
        banner.start();

    }

    private void setWebView(final String url) {

        final WebSettings settings = productDetailWebview.getSettings();
        settings.setJavaScriptEnabled(true);
        productDetailWebview.loadUrl(url);
    }

    @Override
    public void addListener() {


    }

    @Override
    public void setHandler() {
        mHandler = new Handler() {
            @Override
            public void handleMessage(Message msg) {
                super.handleMessage(msg);

                msgWhat = msg.what;

                switch (msg.what) {
                    case MSG.MSG_GET_PRODUCT_INFO_SUCCESS:
                        callBack(msg.obj);
                        break;
                    case MSG.MSG_GET_PRODUCT_INFO_FIELD:
                        showToast(msg.obj.toString());
                        productDetailTvLoading.setText(msg.obj.toString());
                        break;
                    case MSG.MSG_ADD_SHOPPING_CART_ITEM_AGSRV_SUCCESS:
                        clearSelectData();
                        showToast("已加入购物车");
                        break;
                    case MSG.MSG_ADD_SHOPPING_CART_ITEM_AGSRV_FIELD:
                        clearSelectData();
                        showToast(msg.obj.toString());
                        break;
//                    case MSG.MSG_GET_EVALUATE_LIST_SUCCESS: // 评论列表
//                        callBack(msg.obj);
//                        break;
                }
            }
        };

    }

    /**
     * 清除选中属性
     */
    private void clearSelectData() {
        selectedName = "";
        selectedPrice = "";
    }

    @Override
    public void callBack(Object object) {
        switch (msgWhat) {
            case MSG.MSG_GET_PRODUCT_INFO_SUCCESS:
                initData(object.toString());
                break;
//            case MSG.MSG_GET_EVALUATE_LIST_SUCCESS:
//                evaluationVOList = FastJsonUtil.getListBean(object.toString(), "body", "evaContentList", EvaluationVO.class);
//                if (evaluationVOList != null && evaluationVOList.size() > 0) {
//                    FrescoUtil.showImageSmall(evaluationVOList.get(0).getImage(), productDetailIvAppraiserIcon);
//                    productDetailTvAppraiserName.setText(evaluationVOList.get(0).isIsAnonymity() ? Utils.anonymityName(evaluationVOList.get(0).getEvaluatePerson()) : evaluationVOList.get(0).getEvaluatePerson());
//                    productDetailTvAppraiserContent.setText(evaluationVOList.get(0).getContent());
//                } else {
//                    productDetailLLEvaluation.setVisibility(View.GONE);
//                }
//
//                break;
//            case MSG.MSG_GET_EVALUATE_INFO_SUCCESS: // 评论统计
//                try {
//                    String body = new JSONObject(object.toString()).getString("body");
//                    evaluateInfo = new JSONObject(body).getString("evaluateInfo");
//                    productDetailTvEvaluateNum.setText(String.format("(%s)", (evaluateInfo != null ? evaluateInfo.split("\\|")[1] : "0")));
//                } catch (JSONException e) {
//                    LogUtils.e(e.getMessage());
//                }

//                break;
        }

    }

    @Override
    public void rightOnClick() {

    }

    /**
     * 网络数据请求结果 初始化数据
     */
    private void initData(String json) {
        productVO = FastJsonUtil.getBean(json, "body", "productInfo", ProductInfoVO.class);
        lowPrice = FastJsonUtil.getString(json, "lowPrice");
        highPrice = FastJsonUtil.getString(json, "highPrice");
        lowPreferPrice = FastJsonUtil.getString(json, "lowPreferentialPrice");
        highPreferPrice = FastJsonUtil.getString(json, "highPreferentialPrice");
        hasPreferentialPrice = FastJsonUtil.getString(json, "hasPreferentialPrice");

        agricultureList = productVO.getAgricultureProductPriceList();
        hasProperty = productVO.getPriceType();

        productDetailTvLoading.setVisibility(View.GONE);
        productDetailSlidedetails.setVisibility(View.VISIBLE);
        setContent();
    }


    @OnClick({R.id.product_detail_iv_plus, R.id.product_detail_iv_minus, R.id.product_detail_rl_evaluate,
            R.id.product_detail_bt_reserve, R.id.product_detail_layout_cart, R.id.product_detail_bt_add_cart,
            R.id.product_detail_rl_choose_goods_property})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.product_detail_iv_plus:
                buyNumber++;
                productDetailTvNumber.setText(buyNumber + "");
                break;
            case R.id.product_detail_iv_minus:
                if (buyNumber > 1) {
                    buyNumber--;
                    productDetailTvNumber.setText(buyNumber + "");
                }
                break;
            case R.id.product_detail_rl_evaluate: // 商品评价

                GotoUtil.gotoActivity(ProductDetailActivity.this, EvaluateListActivity.class, "productId", productId);
                break;
            case R.id.product_detail_bt_reserve:// 立即购买or立即预定

                if (productVO == null)
                    return;

//                if (2 == productVO.getStatus()) {// 查看最新商品信息(交易快照)
//                    //TODO 最新商品信息
//                    GotoUtil.gotoActivity(ProductDetailActivity.this, ProductDetailActivity.class, "product", productVO);
//                    finish();
//                    BusinessProduct.getProductInfoByProductNo(ProductDetailActivity.this, productVO.getProduct_SN(), mHandler);
//                } else {//

                if (Utils.isLogin(this)) {//登录
                    if ("1".equals(hasProperty)) {// 有产品属性
                        showGoodsPropertyDialog(agricultureList, "1");
                    } else {
                        productVO.setBuyNumber(buyNumber);
                        setProductPrice();
                        GotoUtil.gotoActivity(ProductDetailActivity.this, SubmitOrderActivity.class, "productVO", productVO);
                    }
                } else {
                    Utils.notLoginGoto(this);
                }
//                }
                break;
            case R.id.product_detail_layout_cart:
                //购物车
                if (Utils.isLogin(this)) {
                    GotoUtil.gotoActivity(ProductDetailActivity.this, CartActivity.class);
                } else {
                    Utils.notLoginGoto(this);
                }
                break;
            case R.id.product_detail_bt_add_cart://加入购物车
                if (productVO == null)
                    return;

                if (Utils.isLogin(this)) {
                    if ("1".equals(hasProperty))
                        showGoodsPropertyDialog(agricultureList, "2");
                    else
                        BusinessFarmSystem.addShoppingCartItem(this, productVO.getId(), String.valueOf(buyNumber), "", productVO.getOrgAccId(), mHandler);

                } else {
                    Utils.notLoginGoto(this);
                }
                break;
            case R.id.product_detail_rl_choose_goods_property:// 选择商品属性

                showGoodsPropertyDialog(agricultureList, "3");

                break;
        }
    }

    /**
     * 设置提交订单产品价格
     */
    private void setProductPrice() {
        if ("1".equals(hasPreferentialPrice)) {// 有促销价
            if (productVO.getIsPreSale().equals("1"))// 是否预售
                productVO.setPreSalePrice(lowPreferPrice);
            else
                productVO.setPrice(lowPreferPrice);
        } else {
            if (productVO.getIsPreSale().equals("1"))// 是否预售
                productVO.setPreSalePrice(lowPrice);
            else
                productVO.setPrice(lowPrice);
        }
    }


    String selectedPrice = "";
    String selectedName = "";
    ProductInfoVO.AgricultureProductPriceListBean selectVO;

    /**
     * 弹出商品属性选择框
     */
    private void showGoodsPropertyDialog(List<ProductInfoVO.AgricultureProductPriceListBean> agriculture, final String from) {

        final Dialog dialog = new Dialog(this, R.style.GoodsPropertyDialog);

        View dialogView = LayoutInflater.from(this).inflate(R.layout.dialog_goods_property, null);

        //获得dialog的window窗口
        Window window = dialog.getWindow();

        //设置dialog在屏幕底部
        window.setGravity(Gravity.BOTTOM);

        //设置dialog弹出时的动画效果，从屏幕底部向上弹出
        window.setWindowAnimations(R.style.Animation_Bottom_Dialog);
        window.getDecorView().setPadding(0, 0, 0, 0);

        //获得window窗口的属性
        WindowManager.LayoutParams lp = window.getAttributes();
        //设置窗口宽度为充满全屏
        lp.width = WindowManager.LayoutParams.MATCH_PARENT;
        //设置窗口高度为包裹内容
        lp.height = WindowManager.LayoutParams.WRAP_CONTENT;
        //将设置好的属性set回去
        window.setAttributes(lp);
        //将自定义布局加载到dialog上
        dialog.setContentView(dialogView);

        SimpleDraweeView goodsImage = (SimpleDraweeView) dialogView.findViewById(R.id.dialog_goods_image);
        ImageView ivCancelBtn = (ImageView) dialogView.findViewById(R.id.dialog_iv_cancel);
        final TextView tvSelectedPrice = (TextView) dialogView.findViewById(R.id.dialog_tv_price);
        final TextView tvSelectedName = (TextView) dialogView.findViewById(R.id.dialog_tv_checked_item);
        final TagFlowLayout propertyLayout = (TagFlowLayout) dialogView.findViewById(R.id.dialog_show_goods_specifications);
        ImageView ivMinus = (ImageView) dialogView.findViewById(R.id.dialog_iv_minus);
        ImageView ivPlus = (ImageView) dialogView.findViewById(R.id.dialog_iv_plus);
        final TextView tvNum = (TextView) dialogView.findViewById(R.id.dialog_tv_number);
        Button addCartBtn = (Button) dialogView.findViewById(R.id.dialog_btn_add_cart);// 加入购物车
        Button reserveBtn = (Button) dialogView.findViewById(R.id.dialog_btn_reserve);// 立即购买

        if ("1".equals(hasPreferentialPrice)) {//有促销价格
            tvSelectedPrice.setText(String.format("￥ %s - %s", formatPrice(lowPreferPrice), formatPrice(highPreferPrice)));
        } else {
            if (lowPrice.equals(highPrice))
                tvSelectedPrice.setText(String.format("￥ %s", formatPrice(lowPrice)));
            else
                tvSelectedPrice.setText(String.format("%s - %s元/%s", formatPrice(lowPrice), formatPrice(highPrice), productVO.getUnit().getName()));
        }
        tvSelectedName.setText(String.format("已选择: %s", ""));

        // 是否预售 isPreSale=0 现售  isPreSale=1 预售
        if (productVO.getIsPreSale().equals("1")) {
            addCartBtn.setVisibility(View.GONE);
            reserveBtn.setText("立即预定");
        }

        if ("1".equals(from)) {// 立即购买

            addCartBtn.setVisibility(View.GONE);
            reserveBtn.setText("确定");

        }
        if ("2".equals(from)) {// 加入购物车
            addCartBtn.setVisibility(View.GONE);
            reserveBtn.setText("确定");
        }

        dialog.show();

        FrescoUtil.showImageSmall(productVO.getProductImageList().get(0).getImage(), goodsImage);

        buyNumber = Integer.parseInt(tvNum.getText().toString());

        ivCancelBtn.setOnClickListener(new View.OnClickListener() {// 取消
            @Override
            public void onClick(View v) {
                dialog.dismiss();
            }
        });

        ivMinus.setOnClickListener(new View.OnClickListener() {// 减号
            @Override
            public void onClick(View v) {
                if (buyNumber > 1)
                    buyNumber--;
                tvNum.setText(String.valueOf(buyNumber));
            }
        });

        ivPlus.setOnClickListener(new View.OnClickListener() {// 加号
            @Override
            public void onClick(View v) {
                buyNumber++;
                tvNum.setText(String.valueOf(buyNumber));
            }
        });


        propertyLayout.setAdapter(new TagAdapter<ProductInfoVO.AgricultureProductPriceListBean>(agriculture) {
            @Override
            public View getView(FlowLayout parent, int position, ProductInfoVO.AgricultureProductPriceListBean agricultureProductPriceListBean) {
                TextView tv = (TextView) mInflater.inflate(R.layout.item_goods_property,
                        propertyLayout, false);
                tv.setText(agricultureProductPriceListBean.getAttrName());
                return tv;
            }

        });

        propertyLayout.setOnTagClickListener(new TagFlowLayout.OnTagClickListener() {
            @Override
            public boolean onTagClick(View view, int position, FlowLayout parent) {
                tvSelectedPrice.setText(String.format("￥ %s", agricultureList.get(position).getPreferentialPrice() != null ? formatPrice(agricultureList.get(position).getPreferentialPrice()) : formatPrice(agricultureList.get(position).getPrice())));
                tvSelectedName.setText(String.format("已选择: %s", agricultureList.get(position).getAttrName()));
                selectVO = agricultureList.get(position);
                selectedPrice = agricultureList.get(position).getPreferentialPrice() != null ? agricultureList.get(position).getPreferentialPrice() : agricultureList.get(position).getPrice();
                selectedName = agricultureList.get(position).getAttrName() != null ? agricultureList.get(position).getAttrName() : "";
                return true;
            }
        });

        // 加入购物车
        addCartBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                if (Utils.isLogin(ProductDetailActivity.this)) {
                    if ("".equals(selectedName)) {
                        showToast("请选择产品属性");
                        return;
                    }
                    BusinessFarmSystem.addShoppingCartItem(ProductDetailActivity.this, productVO.getId(), String.valueOf(buyNumber),
                            selectedName, productVO.getOrgAccId(), mHandler);
                    dialog.dismiss();
                } else {
                    Utils.notLoginGoto(ProductDetailActivity.this);
                }

            }
        });

        // 立即预定or立即购买
        reserveBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                if (Utils.isLogin(ProductDetailActivity.this)) {//登录
                    if ("".equals(selectedPrice)) {
                        showToast("请选择产品属性");
                        return;
                    }
                    if ("1".equals(from) || "3".equals(from)) {// 立即购买

                        productVO.setBuyNumber(buyNumber);
                        if (productVO.getIsPreSale().equals("1"))// 预售
                            productVO.setPreSalePrice(selectedPrice);
                        else
                            productVO.setPrice(selectedPrice);

                        Map<String, Object> propertyData = new HashMap<>();
                        propertyData.put("selectVO", selectVO);
                        propertyData.put("productVO", productVO);
                        propertyData.put("selectPrice", selectedPrice);
                        propertyData.put("selectName", selectedName);

                        GotoUtil.gotoActivity(ProductDetailActivity.this, SubmitOrderActivity.class, "propertyData", propertyData);
                        selectedPrice = "";
                    }
                    if ("2".equals(from)) {// 加入购物车
                        BusinessFarmSystem.addShoppingCartItem(ProductDetailActivity.this, productVO.getId(), String.valueOf(buyNumber),
                                selectedName, productVO.getOrgAccId(), mHandler);
                        dialog.dismiss();
                    }
                    dialog.dismiss();
                } else {
                    Utils.notLoginGoto(ProductDetailActivity.this);
                }

            }
        });

    }


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // TODO: add setContentView(...) invocation
        ButterKnife.bind(this);
    }
}
